<template>
  <scroll id="tab-menu">
    <div class="subCategory">
    <div class="subCategory-item" v-for="(item, index) in subCategoriesList" :key="index" 
    @click="subCategoryClick(index)" :class="{active: index == currSubIndex}">
      {{item.name}}
    </div>
  </div>
  </scroll>
</template>

<script>
  import Scroll from 'components/common/scroll/Scroll'
  export default {
    name: "TabContentCategory",
    data() {
      return {
        currSubIndex: 0
      }
    },
    components: {
      Scroll,
    },
    props: {
      subCategoriesList: {
        type: Array,
        default() {
          return [];
        }
      }
    },
    watch: {
      subCategoriesList() {
        this.currSubIndex = 0
      }
    },
    methods: {
      subCategoryClick(index) {
        this.currSubIndex = index;
        this.$emit('selectDetail',index);
      }
    },
  }
</script>

<style scoped>
  .subCategory-item {
    height: 45px;
    line-height: 45px;
    text-align: center;
    font-size: 14px;
  }

  .subCategory-item.active {
    font-weight: 700;
    color: var(--color-high-text);
    background-color: #fff;
    border-right: 3px solid var(--color-high-text);
  }
  #tab-menu {
    background-color: #f6f6f6;
    height: 100%;
    width: 80px;
    box-sizing: border-box;
  }
</style>
